package cn.wolfcode.producer._03_consumer_mode;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

/**
 * @Author: 乱梦天真
 * @Description: TODO
 * @Date: 2020/5/10 17:39
 */
public class Producer {

    public static void main(String[] args) throws Exception {
        //1.创建一个生产者
        DefaultMQProducer producer = new DefaultMQProducer("wolfcode_producer");
        //2.绑定Namesrv
        producer.setNamesrvAddr("127.0.0.1:9876");
        //3.启动生产者
        producer.start();
        //4.新建一个消息
        Message message = new Message("03-consumer-mode", "你好,rokectmq".getBytes("utf-8"));
        //5.发送消息
        SendResult send = producer.send(message);
        System.out.println(send.getMsgId());
        System.out.println(send.getSendStatus());
        //6.关闭资源
        producer.shutdown();
    }

}